//
//  IMCustomMessage.m
//  Pods
//
//  Created by molon on 16/4/8.
//
//

#import "IMCustomMessage.h"
#import "IMCommon.h"

@implementation IMCustomMessage

- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super initWithCoder:coder];
    if (self) {
        self.object = [coder decodeObjectForKey:SELSTR(object)];
    }
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder {
    [super encodeWithCoder:aCoder];
    
    [aCoder encodeObject:self.object forKey:SELSTR(object)];
}

- (id)simpleDescription
{
#define kDefaultDes @"新消息"
    if (IMCONFIGM.simpleDescriptionBlockOfCustomMessage) {
        id des = IMCONFIGM.simpleDescriptionBlockOfCustomMessage(self);
        NSAssert(des&&([des isKindOfClass:[NSString class]]||[des isKindOfClass:[NSAttributedString class]]), @"自定义消息的简要说明信息必须是NSString或者NSAttributedString且不能为nil");
        return des?:kDefaultDes;
    }
    return kDefaultDes;
}

@end
